home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / Sources / FWODPart.cpp < prev    next >
Encoding:
Text File  |  1995-11-08  |  56.3 KB  |  2,257 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWODPart.cpp
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWODPART_H
  13. #include "FWODPart.h"
  14. #endif
  15.  
  16. #ifndef FWPART_H
  17. #include "FWPart.h"
  18. #endif
  19.  
  20. #ifndef FWPRMISE_H
  21. #include "FWPrmise.h"
  22. #endif
  23.  
  24. #ifndef FWDRGDRP_H
  25. #include "FWDrgDrp.h"
  26. #endif
  27.  
  28. #ifndef FWFRMING_H
  29. #include "FWFrming.h"
  30. #endif
  31.  
  32. #ifndef FWPRTITE_H
  33. #include "FWPrtIte.h"
  34. #endif
  35.  
  36. #ifndef FWPRESEN_H
  37. #include "FWPresen.h"
  38. #endif
  39.  
  40. #ifndef FWFRMINF_H
  41. #include "FWFrmInf.h"
  42. #endif
  43.  
  44. #ifndef FWPXYFRM_H
  45. #include "FWPxyFrm.h"
  46. #endif
  47.  
  48. #ifndef FWPROXY_H
  49. #include "FWProxy.h"
  50. #endif
  51.  
  52. #ifndef FWLNKMGR_H
  53. #include "FWLnkMgr.h"
  54. #endif
  55.  
  56. #ifndef FWCMD_H
  57. #include "FWCmd.h"
  58. #endif
  59.  
  60. #ifndef FWBARRAY_H
  61. #include "FWBArray.h"
  62. #endif
  63.  
  64. #ifndef FWODGEOM_H
  65. #include "FWODGeom.h"
  66. #endif
  67.  
  68. #ifndef FWMNUBAR_H
  69. #include "FWMnuBar.h"
  70. #endif
  71.  
  72. #ifndef FWUTIL_H
  73. #include "FWUtil.h"
  74. #endif
  75.  
  76. #ifndef FWCLNINF_H
  77. #include "FWClnInf.h"
  78. #endif
  79.  
  80. #ifndef FWDEBUG_H
  81. #include "FWDebug.h"
  82. #endif
  83.  
  84. #ifndef FWEVENTD_H
  85. #include "FWEventD.h"
  86. #endif
  87.  
  88. // ----- OpenDoc Includes -----
  89.  
  90. #ifndef SOM_Module_OpenDoc_Commands_defined
  91. #include <CmdDefs.xh>
  92. #endif
  93.  
  94. #ifndef SOM_ODFrame_xh
  95. #include <Frame.xh>
  96. #endif
  97.  
  98. #ifndef SOM_ODLinkSource_xh
  99. #include <LinkSrc.xh>
  100. #endif
  101.  
  102. #ifndef SOM_ODLink_xh
  103. #include <Link.xh>
  104. #endif
  105.  
  106. #ifndef SOM_ODClipboard_xh
  107. #include <Clipbd.xh>
  108. #endif
  109.  
  110. #ifndef SOM_ODDraft_xh
  111. #include <Draft.xh>
  112. #endif
  113.  
  114. #ifndef SOM_ODSession_xh
  115. #include <ODSessn.xh>
  116. #endif
  117.  
  118. #ifndef SOM_Module_OpenDoc_StdProps_defined
  119. #include <StdProps.xh>
  120. #endif
  121.  
  122. #ifndef SOM_ODArbitrator_xh
  123. #include <Arbitrat.xh>
  124. #endif
  125.  
  126. #ifndef SOM_Module_OpenDoc_Errors_defined
  127. #include <ErrorDef.xh>
  128. #endif
  129.  
  130. //========================================================================================
  131. // Runtime Information
  132. //========================================================================================
  133.  
  134. #if FW_LIB_EXPORT_PRAGMAS
  135. #pragma lib_export on
  136. #endif
  137.  
  138. #ifdef FW_BUILD_MAC
  139. #pragma segment fwpart2
  140. #endif
  141.  
  142. #ifdef FW_DEBUG
  143. #define FW_kInvalidException "Your mother wears army boots"
  144. #endif
  145.  
  146. //========================================================================================
  147. // class FW_CODPart
  148. //========================================================================================
  149.  
  150. //---------------------------------------------------------------------------------------
  151. //    FW_CODPart::FulfillPromise
  152. //---------------------------------------------------------------------------------------
  153.  
  154. void FW_CODPart::FulfillPromise(Environment *ev, FW_CPart* part, ODStorageUnitView* promiseSUView)
  155. {
  156.     FW_TRY
  157.     {        
  158.         FW_CPromise* promise = NULL;
  159.     
  160.         FW_CByteArray bArray;
  161.         promiseSUView->GetValue(ev, sizeof(FW_CPromise*), bArray);
  162.         bArray.CopyBuffer(&promise, sizeof(FW_CPromise*));
  163.         
  164.         promiseSUView->SetOffset(ev, 0);
  165.         
  166.         unsigned short unfulfillPromise = promise->PrivHandleFulfillPromise(ev, promiseSUView);
  167.         
  168.         if (unfulfillPromise == 0)
  169.             part->DeletePromise(ev, promise->GetStorageKind(ev));
  170.     }
  171.     FW_CATCH_BEGIN
  172.     FW_CATCH_REFERENCE(FW_XException, exception)
  173.     {
  174.         FW_SetException(ev, exception);
  175.     }
  176. #ifdef FW_DEBUG
  177.     FW_CATCH_EVERYTHING()
  178.     {
  179.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  180.         FW_SetODException(ev, kODErrUndefined);
  181.     }
  182. #endif
  183.     FW_CATCH_END
  184. }
  185.  
  186. //---------------------------------------------------------------------------------------
  187. //    FW_CODPart::DragEnter
  188. //---------------------------------------------------------------------------------------
  189.  
  190. ODDragResult FW_CODPart::DragEnter(Environment *ev,
  191.                                     ODDragItemIterator* dragInfo,
  192.                                     ODFacet* facet,
  193.                                     const FW_CPoint& where)
  194. {
  195.     ODDragResult result = FALSE;
  196.     
  197.     FW_TRY
  198.     {
  199.         FW_MDragDroppable* theDrag = FW_MDragDroppable::ODFrameToDragDroppable(ev, facet->GetFrame(ev));
  200.         FW_ASSERT(theDrag != NULL);
  201.                 
  202.         result = theDrag->DragEnter(ev, facet, dragInfo, where);
  203.     }
  204.     FW_CATCH_BEGIN
  205.     FW_CATCH_REFERENCE(FW_XException, exception)
  206.     {
  207.         FW_SetException(ev, exception);
  208.     }
  209. #ifdef FW_DEBUG
  210.     FW_CATCH_EVERYTHING()
  211.     {
  212.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  213.         FW_SetODException(ev, kODErrUndefined);
  214.     }
  215. #endif
  216.     FW_CATCH_END
  217.     
  218.     return result;
  219. }
  220.  
  221. //---------------------------------------------------------------------------------------
  222. //    FW_CODPart::DragWithin
  223. //---------------------------------------------------------------------------------------
  224.  
  225. ODDragResult FW_CODPart::DragWithin(Environment *ev,
  226.                                         ODDragItemIterator* dragInfo,
  227.                                         ODFacet* facet,
  228.                                         const FW_CPoint& where)
  229. {
  230.     ODDragResult result = FALSE;
  231.  
  232.     FW_TRY
  233.     {
  234.         FW_MDragDroppable* theDrag = FW_MDragDroppable::ODFrameToDragDroppable(ev, facet->GetFrame(ev));
  235.         FW_ASSERT(theDrag != NULL);
  236.         
  237.         result = theDrag->DragWithin(ev, facet, dragInfo, where);
  238.     }
  239.     FW_CATCH_BEGIN
  240.     FW_CATCH_REFERENCE(FW_XException, exception)
  241.     {
  242.         FW_SetException(ev, exception);
  243.     }
  244. #ifdef FW_DEBUG
  245.     FW_CATCH_EVERYTHING()
  246.     {
  247.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  248.         FW_SetODException(ev, kODErrUndefined);
  249.     }
  250. #endif
  251.     FW_CATCH_END
  252.     
  253.     return result;
  254. }
  255.  
  256. //---------------------------------------------------------------------------------------
  257. //    FW_CODPart::DragLeave
  258. //---------------------------------------------------------------------------------------
  259.  
  260. void FW_CODPart::DragLeave(Environment *ev,
  261.                             ODFacet* facet,
  262.                             const FW_CPoint& where)
  263. {
  264.     FW_TRY
  265.     {
  266.         FW_MDragDroppable* theDrag = FW_MDragDroppable::ODFrameToDragDroppable(ev, facet->GetFrame(ev));
  267.         FW_ASSERT(theDrag != NULL);
  268.         
  269.         theDrag->DragLeave(ev, facet, where);
  270.     }
  271.     FW_CATCH_BEGIN
  272.     FW_CATCH_REFERENCE(FW_XException, exception)
  273.     {
  274.         FW_SetException(ev, exception);
  275.     }
  276. #ifdef FW_DEBUG
  277.     FW_CATCH_EVERYTHING()
  278.     {
  279.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  280.         FW_SetODException(ev, kODErrUndefined);
  281.     }
  282. #endif
  283.     FW_CATCH_END
  284. }
  285.  
  286. //---------------------------------------------------------------------------------------
  287. //    FW_CODPart::Drop
  288. //---------------------------------------------------------------------------------------
  289.  
  290. ODDropResult FW_CODPart::Drop(Environment *ev,
  291.                                 ODDragItemIterator* dropInfo,
  292.                                 ODFacet* facet,
  293.                                 const FW_CPoint& where)
  294. {
  295.     ODDropResult result = kODDropFail;
  296.     
  297.     FW_TRY
  298.     {
  299.         FW_MDragDroppable* theDrop = FW_MDragDroppable::ODFrameToDragDroppable(ev, facet->GetFrame(ev));
  300.         FW_ASSERT(theDrop != NULL);
  301.         
  302.         result = theDrop->Drop(ev, dropInfo, facet, where);
  303.     }
  304.     FW_CATCH_BEGIN
  305.     FW_CATCH_REFERENCE(FW_XException, exception)
  306.     {
  307.         FW_SetException(ev, exception);
  308.     }
  309. #ifdef FW_DEBUG
  310.     FW_CATCH_EVERYTHING()
  311.     {
  312.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  313.         FW_SetODException(ev, kODErrUndefined);
  314.     }
  315. #endif
  316.     FW_CATCH_END
  317.     
  318.     return result;
  319. }
  320.  
  321. //---------------------------------------------------------------------------------------
  322. //    FW_CODPart::DropCompleted
  323. //---------------------------------------------------------------------------------------
  324.  
  325. void FW_CODPart::DropCompleted(Environment *ev,
  326.                                 ODPart* destPart,
  327.                                 ODDropResult dropResult)
  328. {
  329.     FW_TRY
  330.     {
  331.         FW_DEBUG_MESSAGE("DropCompleted: Not Yet Implemented");
  332.     }
  333.     FW_CATCH_BEGIN
  334.     FW_CATCH_REFERENCE(FW_XException, exception)
  335.     {
  336.         FW_SetException(ev, exception);
  337.     }
  338. #ifdef FW_DEBUG
  339.     FW_CATCH_EVERYTHING()
  340.     {
  341.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  342.         FW_SetODException(ev, kODErrUndefined);
  343.     }
  344. #endif
  345.     FW_CATCH_END
  346. }
  347.  
  348. //---------------------------------------------------------------------------------------
  349. //    FW_CODPart::ContainingPartPropertiesUpdated
  350. //---------------------------------------------------------------------------------------
  351.  
  352. void FW_CODPart::ContainingPartPropertiesUpdated(Environment *ev,
  353.                                                     ODFrame* odFrame,
  354.                                                     ODStorageUnit* propertyUnit)
  355. {
  356.     FW_TRY
  357.     {
  358.         FW_DEBUG_MESSAGE("ContainingPartPropertiesUpdated: Not Yet Implemented");
  359.     }
  360.     FW_CATCH_BEGIN
  361.     FW_CATCH_REFERENCE(FW_XException, exception)
  362.     {
  363.         FW_SetException(ev, exception);
  364.     }
  365. #ifdef FW_DEBUG
  366.     FW_CATCH_EVERYTHING()
  367.     {
  368.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  369.         FW_SetODException(ev, kODErrUndefined);
  370.     }
  371. #endif
  372.     FW_CATCH_END
  373. }
  374.  
  375. //---------------------------------------------------------------------------------------
  376. //    FW_CODPart::AcquireContainingPartProperties
  377. //---------------------------------------------------------------------------------------
  378.  
  379. ODStorageUnit* FW_CODPart::AcquireContainingPartProperties(Environment *ev, ODFrame* odFrame)
  380. {
  381.     ODStorageUnit* su = NULL;
  382.     
  383.     FW_TRY
  384.     {
  385.         FW_DEBUG_MESSAGE("AcquireContainingPartProperties: Not Yet Implemented");
  386.     }
  387.     FW_CATCH_BEGIN
  388.     FW_CATCH_REFERENCE(FW_XException, exception)
  389.     {
  390.         FW_SetException(ev, exception);
  391.     }
  392. #ifdef FW_DEBUG
  393.     FW_CATCH_EVERYTHING()
  394.     {
  395.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  396.         FW_SetODException(ev, kODErrUndefined);
  397.     }
  398. #endif
  399.     FW_CATCH_END
  400.     
  401.     return su;
  402. }
  403.  
  404. //---------------------------------------------------------------------------------------
  405. //    FW_CODPart::RevealFrame
  406. //---------------------------------------------------------------------------------------
  407.  
  408. FW_Boolean FW_CODPart::RevealFrame(Environment *ev,
  409.                                     ODFrame* embeddedFrame,
  410.                                     ODShape* revealShape)
  411. {
  412.     ODBoolean result = FALSE;
  413.     
  414.     FW_TRY
  415.     {
  416.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  417.         FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);
  418.         FW_ASSERT(embeddingFrame);
  419.         
  420.         result = embeddingFrame->RevealFrame(ev, embeddedFrame, revealShape);
  421.     }
  422.     FW_CATCH_BEGIN
  423.     FW_CATCH_REFERENCE(FW_XException, exception)
  424.     {
  425.         FW_SetException(ev, exception);
  426.     }
  427. #ifdef FW_DEBUG
  428.     FW_CATCH_EVERYTHING()
  429.     {
  430.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  431.         FW_SetODException(ev, kODErrUndefined);
  432.     }
  433. #endif
  434.     FW_CATCH_END
  435.     
  436.     return result;
  437. }
  438.  
  439. //---------------------------------------------------------------------------------------
  440. //    FW_CODPart::EmbeddedFrameSpec
  441. //---------------------------------------------------------------------------------------
  442.  
  443. void FW_CODPart::EmbeddedFrameSpec(Environment *ev,
  444.                                     ODFrame* embeddedFrame,
  445.                                     ODObjectSpec* spec)
  446. {
  447.     FW_TRY
  448.     {
  449.         FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  450.         FW_ASSERT(FW_CFrame::ODtoFWFrame(ev, aqODContainingFrame) != NULL);
  451.         
  452.         FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
  453.         if (containingFrame)
  454.             containingFrame->EmbeddedFrameSpec(ev, embeddedFrame, spec);
  455.     }
  456.     FW_CATCH_BEGIN
  457.     FW_CATCH_REFERENCE(FW_XException, exception)
  458.     {
  459.         FW_SetException(ev, exception);
  460.     }
  461. #ifdef FW_DEBUG
  462.     FW_CATCH_EVERYTHING()
  463.     {
  464.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  465.         FW_SetODException(ev, kODErrUndefined);
  466.     }
  467. #endif
  468.     FW_CATCH_END
  469. }
  470.  
  471. //---------------------------------------------------------------------------------------
  472. //    FW_CODPart::DisplayFrameAdded
  473. //---------------------------------------------------------------------------------------
  474.  
  475. void FW_CODPart::DisplayFrameAdded(Environment *ev,
  476.                                     FW_CPart* part, 
  477.                                     ODFrame* odFrame)
  478. {
  479.     FW_TRY
  480.     {
  481.         // ----- Create a global shape and transform if neccessary -----
  482.         FW_PrivCreateShapeTransformMaker(ev, odFrame);
  483.     
  484.         // ----- Look for the presentation -----
  485.         FW_CPresentation* newPresentation = part->PrivGetPresentation(ev, odFrame);
  486.         odFrame->SetPresentation(ev, newPresentation->GetPresentationType(ev));
  487.     
  488.         // ----- Create the frame -----
  489.         FW_CFrame* frame = part->NewFrame(ev, odFrame,  newPresentation, FALSE);
  490.         
  491.         // ----- Create the part Info -----
  492.         FW_CFramePartInfo* framePartInfo = new FW_CFramePartInfo(ev, frame);
  493.         odFrame->SetPartInfo(ev, (ODInfoType)framePartInfo);
  494.     
  495.         // ----- Notify the frame -----
  496.         frame->FrameAdded(ev, FALSE);    // brand new frame
  497.     }
  498.     FW_CATCH_BEGIN
  499.     FW_CATCH_REFERENCE(FW_XException, exception)
  500.     {
  501.         FW_SetException(ev, exception);
  502.     }
  503. #ifdef FW_DEBUG
  504.     FW_CATCH_EVERYTHING()
  505.     {
  506.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  507.         FW_SetODException(ev, kODErrUndefined);
  508.     }
  509. #endif
  510.     FW_CATCH_END
  511. }
  512.  
  513. //---------------------------------------------------------------------------------------
  514. //    FW_CODPart::AttachSourceFrame
  515. //---------------------------------------------------------------------------------------
  516.  
  517. void FW_CODPart::AttachSourceFrame(Environment *ev,
  518.                                     ODFrame* odFrame,
  519.                                     ODFrame* odSourceFrame)
  520. {
  521.     FW_TRY
  522.     {
  523.         if (odSourceFrame != NULL && odFrame != NULL)
  524.         {
  525.             FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  526.             FW_ASSERT(frame);
  527.             
  528.             FW_CFrame* sourceFrame = FW_CFrame::ODtoFWFrame(ev, odSourceFrame);
  529.             FW_ASSERT(sourceFrame != NULL);
  530.             
  531.             frame->PrivAttachSourceFrame(ev, sourceFrame);
  532.         }
  533.     }
  534.     FW_CATCH_BEGIN
  535.     FW_CATCH_REFERENCE(FW_XException, exception)
  536.     {
  537.         FW_SetException(ev, exception);
  538.     }
  539. #ifdef FW_DEBUG
  540.     FW_CATCH_EVERYTHING()
  541.     {
  542.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  543.         FW_SetODException(ev, kODErrUndefined);
  544.     }
  545. #endif
  546.     FW_CATCH_END
  547. }
  548.  
  549. //---------------------------------------------------------------------------------------
  550. //    FW_CODPart::DisplayFrameRemoved
  551. //---------------------------------------------------------------------------------------
  552.  
  553. void FW_CODPart::DisplayFrameRemoved(Environment *ev,
  554.                                         ODFrame* odFrame)
  555. {
  556.     FW_TRY
  557.     {
  558.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  559.         FW_ASSERT(frame);
  560.         
  561.         // ----- Notify the frame that it is going to be removed
  562.         frame->FrameRemoved(ev, FALSE);        // The frame is gone
  563.                 
  564.         // ----- delete the frame (will release odFrame) -----    
  565.         delete frame;
  566.     }
  567.     FW_CATCH_BEGIN
  568.     FW_CATCH_REFERENCE(FW_XException, exception)
  569.     {
  570.         FW_SetException(ev, exception);
  571.     }
  572. #ifdef FW_DEBUG
  573.     FW_CATCH_EVERYTHING()
  574.     {
  575.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  576.         FW_SetODException(ev, kODErrUndefined);
  577.     }
  578. #endif
  579.     FW_CATCH_END
  580. }
  581.  
  582. //---------------------------------------------------------------------------------------
  583. //    FW_CODPart::DisplayFrameConnected
  584. //---------------------------------------------------------------------------------------
  585.  
  586. void FW_CODPart::DisplayFrameConnected(Environment *ev,
  587.                                         ODFrame* odFrame)
  588. {
  589.     FW_TRY
  590.     {
  591.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  592.         FW_ASSERT(frame);
  593.         
  594.         // ----- Notify the frame
  595.         frame->FrameAdded(ev, TRUE);  // From storage
  596.     }
  597.     FW_CATCH_BEGIN
  598.     FW_CATCH_REFERENCE(FW_XException, exception)
  599.     {
  600.         FW_SetException(ev, exception);
  601.     }
  602. #ifdef FW_DEBUG
  603.     FW_CATCH_EVERYTHING()
  604.     {
  605.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  606.         FW_SetODException(ev, kODErrUndefined);
  607.     }
  608. #endif
  609.     FW_CATCH_END
  610. }
  611.  
  612. //---------------------------------------------------------------------------------------
  613. //    FW_CODPart::DisplayFrameClosed
  614. //---------------------------------------------------------------------------------------
  615.  
  616. void FW_CODPart::DisplayFrameClosed(Environment *ev,
  617.                                     ODFrame* odFrame)
  618. {
  619.     FW_TRY
  620.     {
  621.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  622.         FW_ASSERT(frame != NULL);
  623.         
  624.         // ----- Notify the frame that it is going to be closed
  625.         frame->FrameRemoved(ev, TRUE);    // frame stays in storage
  626.         
  627.         // ----- delete it
  628.         delete frame;
  629.     }
  630.     FW_CATCH_BEGIN
  631.     FW_CATCH_REFERENCE(FW_XException, exception)
  632.     {
  633.         FW_SetException(ev, exception);
  634.     }
  635. #ifdef FW_DEBUG
  636.     FW_CATCH_EVERYTHING()
  637.     {
  638.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  639.         FW_SetODException(ev, kODErrUndefined);
  640.     }
  641. #endif
  642.     FW_CATCH_END
  643. }
  644.  
  645. //---------------------------------------------------------------------------------------
  646. //    FW_CODPart::FrameShapeChanged
  647. //---------------------------------------------------------------------------------------
  648.  
  649. void FW_CODPart::FrameShapeChanged(Environment *ev,
  650.                                     ODFrame* odFrame)
  651. {
  652.     FW_TRY
  653.     {
  654.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  655.         FW_ASSERT(frame != NULL);
  656.     
  657.         frame->FrameShapeChanged(ev);
  658.     }
  659.     FW_CATCH_BEGIN
  660.     FW_CATCH_REFERENCE(FW_XException, exception)
  661.     {
  662.         FW_SetException(ev, exception);
  663.     }
  664. #ifdef FW_DEBUG
  665.     FW_CATCH_EVERYTHING()
  666.     {
  667.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  668.         FW_SetODException(ev, kODErrUndefined);
  669.     }
  670. #endif
  671.     FW_CATCH_END
  672. }
  673.  
  674. //---------------------------------------------------------------------------------------
  675. //    FW_CODPart::ViewTypeChanged
  676. //---------------------------------------------------------------------------------------
  677.  
  678. void FW_CODPart::ViewTypeChanged(Environment *ev,
  679.                                     ODFrame* odFrame)
  680. {
  681.     FW_TRY
  682.     {
  683.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  684.         FW_ASSERT(frame != NULL);
  685.         
  686.         ODTypeToken newViewType = odFrame->GetViewType(ev);
  687.         ODTypeToken oldViewType = frame->PrivGetPreviousViewType(ev);
  688.         
  689.         if (newViewType != oldViewType)
  690.         {
  691.             frame->PrivSetPreviousViewType(ev, newViewType);
  692.             frame->ViewTypeChanged(ev, newViewType, oldViewType);
  693.         }
  694.     }
  695.     FW_CATCH_BEGIN
  696.     FW_CATCH_REFERENCE(FW_XException, exception)
  697.     {
  698.         FW_SetException(ev, exception);
  699.     }
  700. #ifdef FW_DEBUG
  701.     FW_CATCH_EVERYTHING()
  702.     {
  703.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  704.         FW_SetODException(ev, kODErrUndefined);
  705.     }
  706. #endif
  707.     FW_CATCH_END
  708. }
  709.  
  710. //---------------------------------------------------------------------------------------
  711. //    FW_CODPart::PresentationChanged
  712. //---------------------------------------------------------------------------------------
  713.  
  714. void FW_CODPart::PresentationChanged(Environment *ev,
  715.                                         ODFrame* odFrame)
  716. {
  717.     FW_TRY
  718.     {
  719.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  720.         FW_ASSERT(frame != NULL);
  721.     
  722.         frame->PresentationChanged(ev);
  723.     }
  724.     FW_CATCH_BEGIN
  725.     FW_CATCH_REFERENCE(FW_XException, exception)
  726.     {
  727.         FW_SetException(ev, exception);
  728.     }
  729. #ifdef FW_DEBUG
  730.     FW_CATCH_EVERYTHING()
  731.     {
  732.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  733.         FW_SetODException(ev, kODErrUndefined);
  734.     }
  735. #endif
  736.     FW_CATCH_END
  737. }
  738.  
  739. //---------------------------------------------------------------------------------------
  740. //    FW_CODPart::SequenceChanged
  741. //---------------------------------------------------------------------------------------
  742.  
  743. void FW_CODPart::SequenceChanged(Environment *ev,
  744.                                     ODFrame* odFrame)
  745. {
  746.     FW_TRY
  747.     {
  748.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  749.         FW_ASSERT(frame != NULL);
  750.     
  751.         frame->SequenceChanged(ev);
  752.     }
  753.     FW_CATCH_BEGIN
  754.     FW_CATCH_REFERENCE(FW_XException, exception)
  755.     {
  756.         FW_SetException(ev, exception);
  757.     }
  758. #ifdef FW_DEBUG
  759.     FW_CATCH_EVERYTHING()
  760.     {
  761.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  762.         FW_SetODException(ev, kODErrUndefined);
  763.     }
  764. #endif
  765.     FW_CATCH_END
  766. }
  767.  
  768. //---------------------------------------------------------------------------------------
  769. //    FW_CODPart::WritePartInfo
  770. //---------------------------------------------------------------------------------------
  771.  
  772. void FW_CODPart::WritePartInfo(Environment *ev,
  773.                                     ODInfoType partInfo,
  774.                                     ODStorageUnitView* storageUnitView)
  775. {
  776.     FW_TRY
  777.     {
  778.         FW_ASSERT(partInfo != NULL);
  779.         
  780.         FW_CFrame* frame = ((FW_CFramePartInfo*)partInfo)->GetFrame();
  781.         FW_ASSERT(frame);
  782.  
  783.         ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  784.     
  785.         FW_CAcquireODPropertyName propName(ev, storageUnitView);
  786.         FW_SUForceFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev));
  787.         
  788.         FW_CAcquireODStorageUnitView suView(ev, su);
  789.         frame->ExternalizeFrame(ev, suView);
  790.     }
  791.     FW_CATCH_BEGIN
  792.     FW_CATCH_REFERENCE(FW_XException, exception)
  793.     {
  794.         FW_SetException(ev, exception);
  795.     }
  796. #ifdef FW_DEBUG
  797.     FW_CATCH_EVERYTHING()
  798.     {
  799.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  800.         FW_SetODException(ev, kODErrUndefined);
  801.     }
  802. #endif
  803.     FW_CATCH_END
  804. }
  805.  
  806. //---------------------------------------------------------------------------------------
  807. //    FW_CODPart::ReadPartInfo
  808. //---------------------------------------------------------------------------------------
  809.  
  810. ODInfoType FW_CODPart::ReadPartInfo(Environment *ev,
  811.                                     FW_CPart* part, 
  812.                                     ODFrame* odFrame,
  813.                                     ODStorageUnitView* storageUnitView)
  814. {
  815.     ODInfoType partInfo = NULL;
  816.     
  817.     FW_TRY
  818.     {
  819.         // ----- Create a global shape and transform if neccessary -----
  820.         FW_PrivCreateShapeTransformMaker(ev, odFrame);
  821.     
  822.         // ----- Determine the presentation -----
  823.         FW_CPresentation* presentation = part->PrivGetPresentation(ev, odFrame);
  824.         odFrame->SetPresentation(ev, presentation->GetPresentationType(ev));
  825.     
  826.         // ----- Create the FW_CFrame object -----
  827.         FW_CFrame* frame = part->NewFrame(ev, odFrame, presentation, TRUE);
  828.         
  829.         // ----- Create the FW_CFramePartInfo object ----- 
  830.         partInfo = (ODInfoType)new FW_CFramePartInfo(ev, frame);
  831.         
  832.         // ----- Internalize the frame -----
  833.         ODStorageUnit* su = storageUnitView->GetStorageUnit(ev);
  834.     
  835.         FW_CAcquireODPropertyName propName(ev, storageUnitView);;
  836.         
  837.         if (FW_SUExistsThenFocus(ev, su, propName, frame->GetPart(ev)->GetPartKind(ev)) )
  838.         {
  839.             FW_CAcquireODStorageUnitView suView(ev, su);
  840.             frame->InternalizeFrame(ev, suView);
  841.         }
  842.     }
  843.     FW_CATCH_BEGIN
  844.     FW_CATCH_REFERENCE(FW_XException, exception)
  845.     {
  846.         FW_SetException(ev, exception);
  847.     }
  848. #ifdef FW_DEBUG
  849.     FW_CATCH_EVERYTHING()
  850.     {
  851.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  852.         FW_SetODException(ev, kODErrUndefined);
  853.     }
  854. #endif
  855.     FW_CATCH_END
  856.     
  857.     return partInfo;
  858. }
  859.  
  860. //---------------------------------------------------------------------------------------
  861. //    FW_CODPart::ClonePartInfo
  862. //---------------------------------------------------------------------------------------
  863.  
  864. void FW_CODPart::ClonePartInfo(Environment *ev,
  865.                                 ODDraftKey key,
  866.                                 ODInfoType partInfo,
  867.                                 ODStorageUnitView* storageUnitView,
  868.                                 ODFrame* scope)
  869. {
  870.     FW_TRY
  871.     {
  872.         FW_CODPart::WritePartInfo(ev, partInfo, storageUnitView);
  873.     
  874. //        FW_ASSERT(partInfo != NULL);
  875. //        FW_CFramePartInfo* framePartInfo = (FW_CFramePartInfo*)partInfo;
  876. //        FW_CFrame* frame = framePartInfo->GetFrame();
  877. //        frame->ClonePartInfo(ev, key, partInfo, storageUnitView, scope);
  878.     }
  879.     FW_CATCH_BEGIN
  880.     FW_CATCH_REFERENCE(FW_XException, exception)
  881.     {
  882.         FW_SetException(ev, exception);
  883.     }
  884. #ifdef FW_DEBUG
  885.     FW_CATCH_EVERYTHING()
  886.     {
  887.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  888.         FW_SetODException(ev, kODErrUndefined);
  889.     }
  890. #endif
  891.     FW_CATCH_END
  892. }
  893.  
  894. //---------------------------------------------------------------------------------------
  895. //    FW_CODPart::Open
  896. //---------------------------------------------------------------------------------------
  897. //    if odFrame is != of NULL we are opening the window from storage. If odFrame == NULL it
  898. //    is the first time.
  899.  
  900. ODID FW_CODPart::Open(Environment *ev,
  901.                         FW_CPart* part,
  902.                         ODFrame* odFrame)
  903. {
  904.     ODID id = 0;
  905.     
  906.     FW_TRY
  907.     {
  908.         FW_CWindow* window = NULL;
  909.         
  910.         if (odFrame)
  911.         {
  912.             if (odFrame->IsRoot(ev))
  913.             {
  914.                 window = new FW_CWindow(ev, part->GetODPart(ev), odFrame);
  915.             }
  916.             else
  917.             {
  918.                 FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  919.                 FW_ASSERT(frame != NULL);
  920.                 return frame->GetPresentation(ev)->ViewInWindow(ev, frame, NULL);
  921.             }
  922.         }
  923.         else
  924.         {
  925.             window = part->NewDocumentWindow(ev);
  926.         }
  927.         FW_ASSERT(window);
  928.             
  929.         // ATTENTION: the order is very important
  930.         window->Show(ev);
  931.         window->Select(ev);
  932.     
  933.         id = window->GetID(ev);
  934.     }
  935.     FW_CATCH_BEGIN
  936.     FW_CATCH_REFERENCE(FW_XException, exception)
  937.     {
  938.         FW_SetException(ev, exception);
  939.     }
  940. #ifdef FW_DEBUG
  941.     FW_CATCH_EVERYTHING()
  942.     {
  943.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  944.         FW_SetODException(ev, kODErrUndefined);
  945.     }
  946. #endif
  947.     FW_CATCH_END
  948.     
  949.     return id;
  950. }
  951.  
  952. //---------------------------------------------------------------------------------------
  953. //    FW_CODPart::RequestEmbeddedFrame
  954. //---------------------------------------------------------------------------------------
  955.  
  956. ODFrame* FW_CODPart::RequestEmbeddedFrame(Environment *ev,
  957.                                             ODFrame* containingFrame,
  958.                                             ODFrame* baseFrame,
  959.                                             ODShape* frameShape,
  960.                                             ODPart* embeddedPart,
  961.                                             ODTypeToken viewType,
  962.                                             ODTypeToken presentation,
  963.                                             FW_Boolean isOverlaid)
  964. {
  965.     ODFrame* frame = NULL;
  966.     
  967.     FW_TRY
  968.     {
  969.         FW_CEmbeddingFrame* embeddingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, containingFrame);
  970.         FW_ASSERT(embeddingFrame);
  971.     
  972.         frame = embeddingFrame->EmbeddedFrameRequested(ev, baseFrame, frameShape, embeddedPart, viewType, presentation, isOverlaid);
  973.     }
  974.     FW_CATCH_BEGIN
  975.     FW_CATCH_REFERENCE(FW_XException, exception)
  976.     {
  977.         FW_SetException(ev, exception);
  978.     }
  979. #ifdef FW_DEBUG
  980.     FW_CATCH_EVERYTHING()
  981.     {
  982.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  983.         FW_SetODException(ev, kODErrUndefined);
  984.     }
  985. #endif
  986.     FW_CATCH_END
  987.     
  988.     return frame;
  989. }
  990.  
  991. //---------------------------------------------------------------------------------------
  992. //    FW_CODPart::RemoveEmbeddedFrame
  993. //---------------------------------------------------------------------------------------
  994.  
  995. void FW_CODPart::RemoveEmbeddedFrame(Environment *ev,
  996.                                         ODFrame* embeddedFrame)
  997. {
  998.     FW_TRY
  999.     {
  1000.         FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1001.         FW_ASSERT(aqODContainingFrame != NULL);
  1002.         FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
  1003.         FW_ASSERT(containingFrame != NULL);
  1004.         
  1005.         // ----- Find the proxyFrame -----
  1006.         FW_CAcquiredProxyFrame aqProxyFrame = containingFrame->PrivAcquireProxyFrame(ev, embeddedFrame->GetID(ev));
  1007.         FW_ASSERT(((const void*)aqProxyFrame) != NULL);
  1008.     
  1009.         containingFrame->PrivRemoveEmbeddedFrame(ev, aqProxyFrame);        // Note: removes the ODEmbeddedFrame from the draft
  1010.     }
  1011.     FW_CATCH_BEGIN
  1012.     FW_CATCH_REFERENCE(FW_XException, exception)
  1013.     {
  1014.         FW_SetException(ev, exception);
  1015.     }
  1016. #ifdef FW_DEBUG
  1017.     FW_CATCH_EVERYTHING()
  1018.     {
  1019.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1020.         FW_SetODException(ev, kODErrUndefined);
  1021.     }
  1022. #endif
  1023.     FW_CATCH_END
  1024. }
  1025.  
  1026. //---------------------------------------------------------------------------------------
  1027. //    FW_CODPart::RequestFrameShape
  1028. //---------------------------------------------------------------------------------------
  1029.  
  1030. ODShape* FW_CODPart::RequestFrameShape(Environment *ev,
  1031.                                         ODFrame* embeddedFrame,
  1032.                                         ODShape* frameShape)
  1033. {
  1034.     ODShape* newFrameShape = NULL;
  1035.     
  1036.     FW_TRY
  1037.     {
  1038.         FW_CAcquiredODFrame aqODContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1039.         
  1040.         FW_CEmbeddingFrame* containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqODContainingFrame);
  1041.         FW_ASSERT(containingFrame);
  1042.         
  1043.         FW_CAcquiredProxyFrame aqProxyFrame = containingFrame->PrivAcquireProxyFrame(ev, embeddedFrame->GetID(ev));
  1044.         FW_ASSERT((const void*)aqProxyFrame != NULL);
  1045.         
  1046.         FW_MProxy *proxy = aqProxyFrame->GetProxy(ev);
  1047.         FW_ASSERT(proxy);
  1048.                 
  1049.         newFrameShape = proxy->FrameShapeRequested(ev, embeddedFrame, frameShape);
  1050.     }
  1051.     FW_CATCH_BEGIN
  1052.     FW_CATCH_REFERENCE(FW_XException, exception)
  1053.     {
  1054.         FW_SetException(ev, exception);
  1055.     }
  1056. #ifdef FW_DEBUG
  1057.     FW_CATCH_EVERYTHING()
  1058.     {
  1059.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1060.         FW_SetODException(ev, kODErrUndefined);
  1061.     }
  1062. #endif
  1063.     FW_CATCH_END
  1064.     
  1065.     return newFrameShape;
  1066. }
  1067.  
  1068. //---------------------------------------------------------------------------------------
  1069. //    FW_CODPart::UsedShapeChanged
  1070. //---------------------------------------------------------------------------------------
  1071.  
  1072. void FW_CODPart::UsedShapeChanged(Environment *ev,
  1073.                                     ODFrame* embeddedFrame)
  1074. {
  1075.     FW_TRY
  1076.     {
  1077.         FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1078.         FW_CEmbeddingFrame *containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);    
  1079.         FW_ASSERT(containingFrame != NULL);    // Should not be called if not an embedding frame or not one of our frame
  1080.     
  1081.         FW_CAcquiredProxyFrame aqProxyFrame = containingFrame->PrivAcquireProxyFrame(ev, embeddedFrame->GetID(ev));
  1082.         
  1083.         //     If proxyFrame is null it means that the embedded part is changing its used shape before
  1084.         //    I had time to finish building all my structures 
  1085.         if ((const void*)aqProxyFrame != NULL)
  1086.         {
  1087.             FW_MProxy *proxy = aqProxyFrame->GetProxy(ev);
  1088.             FW_ASSERT(proxy);
  1089.             
  1090.             proxy->UsedShapeChanged(ev, containingFrame, embeddedFrame);
  1091.         }
  1092.     }
  1093.     FW_CATCH_BEGIN
  1094.     FW_CATCH_REFERENCE(FW_XException, exception)
  1095.     {
  1096.         FW_SetException(ev, exception);
  1097.     }
  1098. #ifdef FW_DEBUG
  1099.     FW_CATCH_EVERYTHING()
  1100.     {
  1101.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1102.         FW_SetODException(ev, kODErrUndefined);
  1103.     }
  1104. #endif
  1105.     FW_CATCH_END
  1106. }
  1107.  
  1108. //---------------------------------------------------------------------------------------
  1109. //    FW_CODPart::AdjustBorderShape
  1110. //---------------------------------------------------------------------------------------
  1111.  
  1112. ODShape* FW_CODPart::AdjustBorderShape(Environment *ev,
  1113.                                         ODFacet* embeddedFacet,
  1114.                                         ODShape* shape)
  1115. {
  1116.     FW_TRY
  1117.     {    
  1118.         if (shape != NULL)
  1119.         {            
  1120.             ODFrame* embeddedFrame = embeddedFacet->GetFrame(ev);
  1121.             FW_CAcquiredODFrame aqContainingFrame = embeddedFrame->AcquireContainingFrame(ev);
  1122.             FW_CEmbeddingFrame *containingFrame = FW_CEmbeddingFrame::ODtoFWEmbeddingFrame(ev, aqContainingFrame);    
  1123.             FW_ASSERT(containingFrame != NULL);    // Should not be called if not an embedding frame or not one of our frame
  1124.         
  1125.             FW_CAcquiredProxyFrame aqProxyFrame = containingFrame->PrivAcquireProxyFrame(ev, embeddedFrame->GetID(ev));
  1126.             FW_ASSERT((const void*)aqProxyFrame != NULL);
  1127.             
  1128.             FW_MProxy *proxy = aqProxyFrame->GetProxy(ev);
  1129.             FW_ASSERT(proxy);
  1130.             
  1131.             // ----- I need to acquire it before returning it -----        
  1132.             shape->Acquire(ev);
  1133.  
  1134.             // ----- Put it in embeddingFrame content coordinate -----
  1135.             FW_CAcquiredODTransform aqExternalxForm = embeddedFacet->AcquireExternalTransform(ev, NULL);
  1136.             shape->Transform(ev, aqExternalxForm);
  1137.             
  1138.             // ----- Put it in embeddingFrame frame coordinate -----
  1139.             FW_CAcquiredODTransform aqInternalxform = containingFrame->AcquireInternalTransform(ev, NULL);
  1140.             shape->Transform(ev, aqInternalxform);          
  1141.  
  1142.             // ----- Intersect with content shape -----
  1143.             FW_CAcquiredODShape aqContentShape = containingFrame->AcquireContentShape(ev);
  1144.             shape->Intersect(ev, aqContentShape);
  1145.  
  1146.             // ----- Call the proxy to intersect with content -----
  1147.             proxy->AdjustBorderShape(ev, containingFrame, embeddedFacet, shape);
  1148.  
  1149.             // ----- Put it back in embeddedFacet frame coordinate -----
  1150.             shape->InverseTransform(ev, aqInternalxform);          
  1151.             shape->InverseTransform(ev, aqExternalxForm);
  1152.         }
  1153.     }
  1154.     FW_CATCH_BEGIN
  1155.     FW_CATCH_REFERENCE(FW_XException, exception)
  1156.     {
  1157.         FW_SetException(ev, exception);
  1158.     }
  1159. #ifdef FW_DEBUG
  1160.     FW_CATCH_EVERYTHING()
  1161.     {
  1162.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1163.         FW_SetODException(ev, kODErrUndefined);
  1164.     }
  1165. #endif
  1166.     FW_CATCH_END
  1167.     
  1168.     return shape;
  1169. }
  1170.  
  1171. //---------------------------------------------------------------------------------------
  1172. //    FW_CODPart::FacetAdded
  1173. //---------------------------------------------------------------------------------------
  1174.  
  1175. void FW_CODPart::FacetAdded(Environment *ev, ODFacet* facet)
  1176. {
  1177.     FW_TRY
  1178.     {
  1179.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1180.         FW_ASSERT(frame != NULL);
  1181.         
  1182.         frame->FacetAdded(ev, facet);
  1183.     }
  1184.     FW_CATCH_BEGIN
  1185.     FW_CATCH_REFERENCE(FW_XException, exception)
  1186.     {
  1187.         FW_SetException(ev, exception);
  1188.     }
  1189. #ifdef FW_DEBUG
  1190.     FW_CATCH_EVERYTHING()
  1191.     {
  1192.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1193.         FW_SetODException(ev, kODErrUndefined);
  1194.     }
  1195. #endif
  1196.     FW_CATCH_END
  1197. }
  1198.  
  1199. //---------------------------------------------------------------------------------------
  1200. //    FW_CODPart::FacetRemoved
  1201. //---------------------------------------------------------------------------------------
  1202.  
  1203. void FW_CODPart::FacetRemoved(Environment *ev, ODFacet* facet)
  1204. {
  1205.     FW_TRY
  1206.     {
  1207.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1208.         FW_ASSERT(frame != NULL);
  1209.         
  1210.         frame->FacetRemoved(ev, facet);
  1211.     }
  1212.     FW_CATCH_BEGIN
  1213.     FW_CATCH_REFERENCE(FW_XException, exception)
  1214.     {
  1215.         FW_SetException(ev, exception);
  1216.     }
  1217. #ifdef FW_DEBUG
  1218.     FW_CATCH_EVERYTHING()
  1219.     {
  1220.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1221.         FW_SetODException(ev, kODErrUndefined);
  1222.     }
  1223. #endif
  1224.     FW_CATCH_END
  1225. }
  1226.  
  1227. //---------------------------------------------------------------------------------------
  1228. //    FW_CODPart::CanvasChanged
  1229. //---------------------------------------------------------------------------------------
  1230.  
  1231. void FW_CODPart::CanvasChanged(Environment *ev, ODFacet* facet)
  1232. {
  1233.     FW_TRY
  1234.     {
  1235.         FW_CGraphicDevice* graphicDevice = FW_CFacetPartInfo::GetFacetGraphicDevice(ev, facet);
  1236.         if(graphicDevice != NULL)
  1237.             graphicDevice->CanvasChanged(ev, facet->GetCanvas(ev));
  1238.     }
  1239.     FW_CATCH_BEGIN
  1240.     FW_CATCH_REFERENCE(FW_XException, exception)
  1241.     {
  1242.         FW_SetException(ev, exception);
  1243.     }
  1244. #ifdef FW_DEBUG
  1245.     FW_CATCH_EVERYTHING()
  1246.     {
  1247.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1248.         FW_SetODException(ev, kODErrUndefined);
  1249.     }
  1250. #endif
  1251.     FW_CATCH_END
  1252. }
  1253.  
  1254. //---------------------------------------------------------------------------------------
  1255. //    FW_CODPart::GeometryChanged
  1256. //---------------------------------------------------------------------------------------
  1257.  
  1258. void FW_CODPart::GeometryChanged(Environment *ev,
  1259.                                     ODFacet* facet,
  1260.                                     FW_Boolean clipShapeChanged,
  1261.                                     FW_Boolean externalTransformChanged)
  1262. {
  1263.     FW_TRY
  1264.     {
  1265.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1266.         FW_ASSERT(frame != NULL);
  1267.         frame->GeometryChanged(ev, facet, clipShapeChanged, externalTransformChanged);
  1268.     }
  1269.     FW_CATCH_BEGIN
  1270.     FW_CATCH_REFERENCE(FW_XException, exception)
  1271.     {
  1272.         FW_SetException(ev, exception);
  1273.     }
  1274. #ifdef FW_DEBUG
  1275.     FW_CATCH_EVERYTHING()
  1276.     {
  1277.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1278.         FW_SetODException(ev, kODErrUndefined);
  1279.     }
  1280. #endif
  1281.     FW_CATCH_END
  1282. }
  1283.  
  1284. //---------------------------------------------------------------------------------------
  1285. //    FW_CODPart::Draw
  1286. //---------------------------------------------------------------------------------------
  1287.  
  1288. void FW_CODPart::Draw(Environment *ev,
  1289.                         ODFacet* facet,
  1290.                         ODShape* invalidShape)
  1291. {
  1292.     FW_TRY
  1293.     {
  1294.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, facet->GetFrame(ev));
  1295.         FW_ASSERT(frame != NULL);
  1296.     
  1297.         frame->HandleDraw(ev, facet, invalidShape);
  1298.     }
  1299.     FW_CATCH_BEGIN
  1300.     FW_CATCH_REFERENCE(FW_XException, exception)
  1301.     {
  1302.         FW_SetException(ev, exception);
  1303.     }
  1304. #ifdef FW_DEBUG
  1305.     FW_CATCH_EVERYTHING()
  1306.     {
  1307.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1308.         FW_SetODException(ev, kODErrUndefined);
  1309.     }
  1310. #endif
  1311.     FW_CATCH_END
  1312. }
  1313.  
  1314. //---------------------------------------------------------------------------------------
  1315. //    FW_CODPart::CanvasUpdated
  1316. //---------------------------------------------------------------------------------------
  1317.  
  1318. void FW_CODPart::CanvasUpdated(Environment *ev, ODCanvas* canvas)
  1319. {
  1320.     FW_TRY
  1321.     {
  1322.         FW_DEBUG_MESSAGE("CanvasUpdate: Not Yet Implemented");
  1323.     }
  1324.     FW_CATCH_BEGIN
  1325.     FW_CATCH_REFERENCE(FW_XException, exception)
  1326.     {
  1327.         FW_SetException(ev, exception);
  1328.     }
  1329. #ifdef FW_DEBUG
  1330.     FW_CATCH_EVERYTHING()
  1331.     {
  1332.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1333.         FW_SetODException(ev, kODErrUndefined);
  1334.     }
  1335. #endif
  1336.     FW_CATCH_END
  1337. }
  1338.  
  1339. //---------------------------------------------------------------------------------------
  1340. //    FW_CODPart::HighlightChanged
  1341. //---------------------------------------------------------------------------------------
  1342.  
  1343. void FW_CODPart::HighlightChanged(Environment *ev, ODFacet* facet)
  1344. {
  1345.     FW_TRY
  1346.     {
  1347.         FW_DEBUG_MESSAGE("HighlightChanged: Not Yet Implemented");
  1348.     }
  1349.     FW_CATCH_BEGIN
  1350.     FW_CATCH_REFERENCE(FW_XException, exception)
  1351.     {
  1352.         FW_SetException(ev, exception);
  1353.     }
  1354. #ifdef FW_DEBUG
  1355.     FW_CATCH_EVERYTHING()
  1356.     {
  1357.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1358.         FW_SetODException(ev, kODErrUndefined);
  1359.     }
  1360. #endif
  1361.     FW_CATCH_END
  1362. }
  1363.  
  1364. //---------------------------------------------------------------------------------------
  1365. //    FW_CODPart::GetPrintResolution
  1366. //---------------------------------------------------------------------------------------
  1367.  
  1368. unsigned long FW_CODPart::GetPrintResolution(Environment *ev, ODFrame* odFrame)
  1369. {
  1370.     ODULong resolution = 0;
  1371.     
  1372.     FW_TRY
  1373.     {
  1374.         FW_DEBUG_MESSAGE("GetPrintResolution: Not Yet Implemented");
  1375.     }
  1376.     FW_CATCH_BEGIN
  1377.     FW_CATCH_REFERENCE(FW_XException, exception)
  1378.     {
  1379.         FW_SetException(ev, exception);
  1380.     }
  1381. #ifdef FW_DEBUG
  1382.     FW_CATCH_EVERYTHING()
  1383.     {
  1384.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1385.         FW_SetODException(ev, kODErrUndefined);
  1386.     }
  1387. #endif
  1388.     FW_CATCH_END
  1389.     
  1390.     return resolution;
  1391. }
  1392.  
  1393. //---------------------------------------------------------------------------------------
  1394. //    FW_CODPart::CreateLink
  1395. //---------------------------------------------------------------------------------------
  1396.  
  1397. ODLinkSource* FW_CODPart::CreateLink(Environment *ev, FW_CPart* part, ODByteArray* data)
  1398. {
  1399.     ODLinkSource* odLinkSource = NULL;
  1400.  
  1401.     FW_TRY
  1402.     {
  1403.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1404.         FW_ASSERT(linkMgr);
  1405.         odLinkSource = linkMgr->CreateLink(ev, data);
  1406.     }
  1407.     FW_CATCH_BEGIN
  1408.     FW_CATCH_REFERENCE(FW_XException, exception)
  1409.     {
  1410.         FW_SetException(ev, exception);
  1411.     }
  1412. #ifdef FW_DEBUG
  1413.     FW_CATCH_EVERYTHING()
  1414.     {
  1415.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1416.         FW_SetODException(ev, kODErrUndefined);
  1417.     }
  1418. #endif
  1419.     FW_CATCH_END
  1420.     
  1421.     return odLinkSource;
  1422. }
  1423.  
  1424. //---------------------------------------------------------------------------------------
  1425. //    FW_CODPart::LinkUpdated
  1426. //---------------------------------------------------------------------------------------
  1427.  
  1428. void FW_CODPart::LinkUpdated(Environment *ev,
  1429.                                 FW_CPart* part,
  1430.                                 ODLink* updatedLink,
  1431.                                 ODUpdateID updateID)
  1432. {
  1433.     FW_TRY
  1434.     {
  1435.         // Notify all the subscribers that are destinations of the updated link
  1436.         FW_CPartSubscribeIterator iter(part);
  1437.         for (FW_CSubscribeLink* link = iter.First(); iter.IsNotComplete(); link = iter.Next())
  1438.         {
  1439.             if (updatedLink->IsEqualTo(ev, link->GetODLink(ev)) && (link->IsAutoUpdate(ev)))
  1440.             {
  1441.                 link->LinkUpdated(ev, updateID);
  1442.             }
  1443.         }
  1444.     }
  1445.     FW_CATCH_BEGIN
  1446.     FW_CATCH_REFERENCE(FW_XException, exception)
  1447.     {
  1448.         FW_SetException(ev, exception);
  1449.     }
  1450. #ifdef FW_DEBUG
  1451.     FW_CATCH_EVERYTHING()
  1452.     {
  1453.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1454.         FW_SetODException(ev, kODErrUndefined);
  1455.     }
  1456. #endif
  1457.     FW_CATCH_END
  1458. }
  1459.  
  1460. //---------------------------------------------------------------------------------------
  1461. //    FW_CODPart::RevealLink
  1462. //---------------------------------------------------------------------------------------
  1463.  
  1464. void FW_CODPart::RevealLink(Environment *ev, FW_CPart* part, ODLinkSource* linkSource)
  1465. {
  1466.     FW_TRY
  1467.     {
  1468.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1469.         FW_ASSERT(linkMgr);
  1470.         linkMgr->RevealLink(ev, linkSource);
  1471.     }
  1472.     FW_CATCH_BEGIN
  1473.     FW_CATCH_REFERENCE(FW_XException, exception)
  1474.     {
  1475.         FW_SetException(ev, exception);
  1476.     }
  1477. #ifdef FW_DEBUG
  1478.     FW_CATCH_EVERYTHING()
  1479.     {
  1480.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1481.         FW_SetODException(ev, kODErrUndefined);
  1482.     }
  1483. #endif
  1484.     FW_CATCH_END
  1485. }
  1486.  
  1487. //---------------------------------------------------------------------------------------
  1488. //    FW_CODPart::EmbeddedFrameUpdated
  1489. //---------------------------------------------------------------------------------------
  1490.  
  1491. void FW_CODPart::EmbeddedFrameUpdated(Environment *ev,
  1492.                                       FW_CPart* part,
  1493.                                       ODFrame* odFrame,
  1494.                                       ODUpdateID updateID)
  1495. {
  1496.     FW_TRY
  1497.     {
  1498.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1499.         if (linkMgr)
  1500.             linkMgr->DoUpdateLinks(ev, odFrame, updateID);
  1501.     }
  1502.     FW_CATCH_BEGIN
  1503.     FW_CATCH_REFERENCE(FW_XException, exception)
  1504.     {
  1505.         FW_SetException(ev, exception);
  1506.     }
  1507. #ifdef FW_DEBUG
  1508.     FW_CATCH_EVERYTHING()
  1509.     {
  1510.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1511.         FW_SetODException(ev, kODErrUndefined);
  1512.     }
  1513. #endif
  1514.     FW_CATCH_END
  1515. }
  1516.  
  1517. //---------------------------------------------------------------------------------------
  1518. //    FW_CODPart::EditInLinkAttempted
  1519. //---------------------------------------------------------------------------------------
  1520.  
  1521. FW_Boolean FW_CODPart::EditInLinkAttempted(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1522. {
  1523.     FW_Boolean result = FALSE;
  1524.     
  1525.     FW_TRY
  1526.     {
  1527.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1528.         FW_ASSERT(linkMgr);
  1529.         result = linkMgr->EditInLinkAttempted(ev, odFrame);
  1530.     }
  1531.     FW_CATCH_BEGIN
  1532.     FW_CATCH_REFERENCE(FW_XException, exception)
  1533.     {
  1534.         FW_SetException(ev, exception);
  1535.     }
  1536. #ifdef FW_DEBUG
  1537.     FW_CATCH_EVERYTHING()
  1538.     {
  1539.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1540.         FW_SetODException(ev, kODErrUndefined);
  1541.     }
  1542. #endif
  1543.     FW_CATCH_END
  1544.     
  1545.     return result;
  1546. }
  1547.  
  1548. //---------------------------------------------------------------------------------------
  1549. //    FW_CODPart::LinkStatusChanged
  1550. //---------------------------------------------------------------------------------------
  1551.  
  1552. void FW_CODPart::LinkStatusChanged(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1553. {
  1554.     FW_TRY
  1555.     {
  1556.         FW_CLinkManager* linkMgr = part->GetLinkManager(ev);
  1557.         if (linkMgr)
  1558.             linkMgr->DoChangeLinkStatus(ev, odFrame);
  1559.         else
  1560.             part->LinkStatusChanged(ev, odFrame);
  1561.     }
  1562.     FW_CATCH_BEGIN
  1563.     FW_CATCH_REFERENCE(FW_XException, exception)
  1564.     {
  1565.         FW_SetException(ev, exception);
  1566.     }
  1567. #ifdef FW_DEBUG
  1568.     FW_CATCH_EVERYTHING()
  1569.     {
  1570.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1571.         FW_SetODException(ev, kODErrUndefined);
  1572.     }
  1573. #endif
  1574.     FW_CATCH_END
  1575. }
  1576.  
  1577. //---------------------------------------------------------------------------------------
  1578. //    FW_CODPart::BeginRelinquishFocus
  1579. //---------------------------------------------------------------------------------------
  1580.  
  1581. FW_Boolean FW_CODPart::BeginRelinquishFocus(Environment *ev,
  1582.                                             FW_CPart* part,
  1583.                                             ODTypeToken focus,
  1584.                                             ODFrame* odOwnerFrame,
  1585.                                             ODFrame* proposedFrame)
  1586. {
  1587.     FW_Boolean result = FALSE;
  1588.     
  1589.     FW_TRY
  1590.     {
  1591.         if (focus == FW_CPart::gModalFocusToken)
  1592.         {
  1593.             FW_CAcquiredODPart aqODPart = proposedFrame->AcquirePart(ev);
  1594.              return (aqODPart == part->GetODPart(ev));
  1595.         }
  1596.     
  1597.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, odOwnerFrame);
  1598.         result = frame->BeginRelinquishFocus(ev, focus, proposedFrame);
  1599.     }
  1600.     FW_CATCH_BEGIN
  1601.     FW_CATCH_REFERENCE(FW_XException, exception)
  1602.     {
  1603.         FW_SetException(ev, exception);
  1604.     }
  1605. #ifdef FW_DEBUG
  1606.     FW_CATCH_EVERYTHING()
  1607.     {
  1608.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1609.         FW_SetODException(ev, kODErrUndefined);
  1610.     }
  1611. #endif
  1612.     FW_CATCH_END
  1613.     
  1614.     return result;
  1615. }
  1616.  
  1617. //---------------------------------------------------------------------------------------
  1618. //    FW_CODPart::CommitRelinquishFocus
  1619. //---------------------------------------------------------------------------------------
  1620.  
  1621. void FW_CODPart::CommitRelinquishFocus(Environment *ev,
  1622.                                         ODTypeToken focus,
  1623.                                         ODFrame* odOwnerFrame,
  1624.                                         ODFrame* odProposedFrame)
  1625. {
  1626.     FW_TRY
  1627.     {
  1628.         FW_CFrame* ownerFrame = FW_CFrame::ODtoFWFrame(ev, odOwnerFrame);
  1629.         FW_ASSERT(ownerFrame != NULL);
  1630.     
  1631.         ownerFrame->CommitRelinquishFocus(ev, focus, odProposedFrame);
  1632.     }
  1633.     FW_CATCH_BEGIN
  1634.     FW_CATCH_REFERENCE(FW_XException, exception)
  1635.     {
  1636.         FW_SetException(ev, exception);
  1637.     }
  1638. #ifdef FW_DEBUG
  1639.     FW_CATCH_EVERYTHING()
  1640.     {
  1641.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1642.         FW_SetODException(ev, kODErrUndefined);
  1643.     }
  1644. #endif
  1645.     FW_CATCH_END
  1646. }
  1647.  
  1648. //---------------------------------------------------------------------------------------
  1649. //    FW_CODPart::AbortRelinquishFocus
  1650. //---------------------------------------------------------------------------------------
  1651.  
  1652. void FW_CODPart::AbortRelinquishFocus(Environment *ev,
  1653.                                         ODTypeToken focus,
  1654.                                         ODFrame* ownerFrame,
  1655.                                         ODFrame* proposedFrame)
  1656. {
  1657.     FW_TRY
  1658.     {
  1659.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1660.         FW_ASSERT(frame);
  1661.         
  1662.         frame->AbortRelinquishFocus(ev, focus, proposedFrame);
  1663.     }
  1664.     FW_CATCH_BEGIN
  1665.     FW_CATCH_REFERENCE(FW_XException, exception)
  1666.     {
  1667.         FW_SetException(ev, exception);
  1668.     }
  1669. #ifdef FW_DEBUG
  1670.     FW_CATCH_EVERYTHING()
  1671.     {
  1672.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1673.         FW_SetODException(ev, kODErrUndefined);
  1674.     }
  1675. #endif
  1676.     FW_CATCH_END
  1677. }
  1678.  
  1679. //---------------------------------------------------------------------------------------
  1680. //    FW_CODPart::FocusAcquired
  1681. //---------------------------------------------------------------------------------------
  1682.  
  1683. void FW_CODPart::FocusAcquired(Environment *ev,
  1684.                                 ODTypeToken focus,
  1685.                                 ODFrame* ownerFrame)
  1686. {
  1687.     FW_TRY
  1688.     {
  1689.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1690.         FW_ASSERT(frame != NULL);
  1691.         
  1692.         frame->FocusStateChanged(ev, focus, TRUE, NULL);
  1693.     }
  1694.     FW_CATCH_BEGIN
  1695.     FW_CATCH_REFERENCE(FW_XException, exception)
  1696.     {
  1697.         FW_SetException(ev, exception);
  1698.     }
  1699. #ifdef FW_DEBUG
  1700.     FW_CATCH_EVERYTHING()
  1701.     {
  1702.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1703.         FW_SetODException(ev, kODErrUndefined);
  1704.     }
  1705. #endif
  1706.     FW_CATCH_END
  1707. }
  1708.  
  1709. //---------------------------------------------------------------------------------------
  1710. //    FW_CODPart::FocusLost
  1711. //---------------------------------------------------------------------------------------
  1712.  
  1713. void FW_CODPart::FocusLost(Environment *ev,
  1714.                             ODTypeToken focus,
  1715.                             ODFrame* ownerFrame)
  1716. {
  1717.     FW_TRY
  1718.     {
  1719.         FW_CFrame* frame = FW_CFrame::ODtoFWFrame(ev, ownerFrame);
  1720.         FW_ASSERT(frame != NULL);
  1721.         
  1722.         frame->FocusStateChanged(ev, focus, FALSE, NULL);
  1723.     }
  1724.     FW_CATCH_BEGIN
  1725.     FW_CATCH_REFERENCE(FW_XException, exception)
  1726.     {
  1727.         FW_SetException(ev, exception);
  1728.     }
  1729. #ifdef FW_DEBUG
  1730.     FW_CATCH_EVERYTHING()
  1731.     {
  1732.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1733.         FW_SetODException(ev, kODErrUndefined);
  1734.     }
  1735. #endif
  1736.     FW_CATCH_END
  1737. }
  1738.  
  1739. //---------------------------------------------------------------------------------------
  1740. //    FW_CODPart::CloneInto
  1741. //---------------------------------------------------------------------------------------
  1742.  
  1743. void FW_CODPart::CloneInto(Environment *ev,
  1744.                             FW_CPart* part,
  1745.                             ODDraftKey key,
  1746.                             ODStorageUnit* toSU,
  1747.                             ODFrame* scope)
  1748. {
  1749.     FW_TRY
  1750.     {
  1751.         // Since this method may be called multiple times during one Cloning
  1752.         // transaction, the Part should check to see whether it really needs
  1753.         // to write out any data
  1754.         if (toSU->Exists(ev, kODPropContents, part->GetPartKind(ev), 0))
  1755.             return;
  1756.     
  1757.         part->AddProperties(ev, toSU);
  1758.         
  1759.         part->PrivCloneInto(ev, key, toSU, scope);
  1760.     }
  1761.     FW_CATCH_BEGIN
  1762.     FW_CATCH_REFERENCE(FW_XException, exception)
  1763.     {
  1764.         FW_SetException(ev, exception);
  1765.     }
  1766. #ifdef FW_DEBUG
  1767.     FW_CATCH_EVERYTHING()
  1768.     {
  1769.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1770.         FW_SetODException(ev, kODErrUndefined);
  1771.     }
  1772. #endif
  1773.     FW_CATCH_END
  1774. }
  1775.  
  1776. //---------------------------------------------------------------------------------------
  1777. //    FW_CODPart::ExternalizeKinds
  1778. //---------------------------------------------------------------------------------------
  1779.  
  1780. void FW_CODPart::ExternalizeKinds(Environment *ev, ODTypeList* kindset)
  1781. {
  1782.     FW_TRY
  1783.     {
  1784.         FW_DEBUG_MESSAGE("ExternalizeKinds: Not Yet Implemented");
  1785.     }
  1786.     FW_CATCH_BEGIN
  1787.     FW_CATCH_REFERENCE(FW_XException, exception)
  1788.     {
  1789.         FW_SetException(ev, exception);
  1790.     }
  1791. #ifdef FW_DEBUG
  1792.     FW_CATCH_EVERYTHING()
  1793.     {
  1794.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1795.         FW_SetODException(ev, kODErrUndefined);
  1796.     }
  1797. #endif
  1798.     FW_CATCH_END
  1799. }
  1800.  
  1801. //---------------------------------------------------------------------------------------
  1802. //    FW_CODPart::ChangeKind
  1803. //---------------------------------------------------------------------------------------
  1804.  
  1805. void FW_CODPart::ChangeKind(Environment *ev, ODType kind)
  1806. {
  1807.     FW_TRY
  1808.     {
  1809.         FW_DEBUG_MESSAGE("ChangeKind: Not Yet Implemented");
  1810.     }
  1811.     FW_CATCH_BEGIN
  1812.     FW_CATCH_REFERENCE(FW_XException, exception)
  1813.     {
  1814.         FW_SetException(ev, exception);
  1815.     }
  1816. #ifdef FW_DEBUG
  1817.     FW_CATCH_EVERYTHING()
  1818.     {
  1819.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1820.         FW_SetODException(ev, kODErrUndefined);
  1821.     }
  1822. #endif
  1823.     FW_CATCH_END
  1824. }
  1825.  
  1826. //---------------------------------------------------------------------------------------
  1827. //    FW_CODPart::HandleEvent
  1828. //---------------------------------------------------------------------------------------
  1829.  
  1830. FW_Boolean FW_CODPart::HandleEvent(Environment *ev,
  1831.                                     FW_CPart* part,
  1832.                                     ODEventData* event,
  1833.                                     ODFrame* odFrame,
  1834.                                     ODFacet* odFacet,
  1835.                                     ODEventInfo* eventInfo)
  1836. {
  1837.     //     Set the default value to TRUE so if Dispatch fails while trying to handle the
  1838.     //    event I will still returns true. Dispatch will anyway returns FALSE if I don't
  1839.     //    handle the event. It is unlikely that I will fail in not handling the event.
  1840.     ODBoolean handled = TRUE;
  1841.     
  1842.     FW_TRY
  1843.     {
  1844.         handled = part->GetEventDispatcher(ev)->Dispatch(ev, event, odFrame, odFacet, eventInfo);
  1845.  
  1846. /*
  1847.         if (fDialogToClose)
  1848.         {
  1849.             // NOTICE: Closing a Window generates an event for that window. So to avoid
  1850.             // closing the window more than once, first save it in a local and set
  1851.             // fDialogToClose NULL, then call CloseWindow.
  1852.             
  1853.             FW_CWindow* dialogWindow = fDialogToClose;
  1854.             fDialogToClose = NULL;
  1855.             
  1856.             ODFrame* rootFrame = dialogWindow->GetODWindow(ev)->GetRootFrame(ev);
  1857.             part->GetSession(ev)->GetArbitrator(ev)->RelinquishFocus(ev, gModalFocusToken, rootFrame);
  1858.             part->FocusLost(ev, gModalFocusToken, rootFrame);
  1859.             part->EnableMenuBar(ev, TRUE);
  1860.             
  1861.             // [HLX] Don't know what to do
  1862.             FW_DEBUG_MESSAGE("CloseWindow doesn't extist anymore...");
  1863. //            dialogWindow->CloseWindow(ev);
  1864.         }
  1865. */
  1866.     }
  1867.     FW_CATCH_BEGIN
  1868.     FW_CATCH_REFERENCE(FW_XException, exception)
  1869.     {
  1870.         FW_SetException(ev, exception);
  1871.     }
  1872. #ifdef FW_DEBUG
  1873.     FW_CATCH_EVERYTHING()
  1874.     {
  1875.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1876.         FW_SetODException(ev, kODErrUndefined);
  1877.     }
  1878. #endif
  1879.     FW_CATCH_END
  1880.     
  1881.     return handled;
  1882. }
  1883.  
  1884. //---------------------------------------------------------------------------------------
  1885. //    FW_CODPart::AdjustMenus
  1886. //---------------------------------------------------------------------------------------
  1887.  
  1888. void FW_CODPart::AdjustMenus(Environment *ev, FW_CPart* part, ODFrame* odFrame)
  1889. {
  1890.     FW_TRY
  1891.     {
  1892.         FW_CFrame *frame = FW_CFrame::ODtoFWFrame(ev, odFrame);
  1893.         FW_ASSERT(frame != NULL);
  1894.         
  1895.         // ----- Look if this frame has the menuFocus -----
  1896.         ODArbitrator* arbitrator = part->GetSession(ev)->GetArbitrator(ev);
  1897.         FW_CAcquiredODFrame aqFrameWithFocus = arbitrator->AcquireFocusOwner(ev, FW_CPart::gMenuFocusToken);
  1898.         
  1899.         FW_CMenuBar *menuBar = part->GetMenuBar(ev);
  1900.         menuBar->DisableAll(ev);
  1901.     
  1902.         FW_Boolean hasMenuFocus = (aqFrameWithFocus == odFrame);
  1903.         FW_Boolean rootFrame = frame->IsRoot(ev);
  1904.  
  1905.         FW_MEventHandler* target = frame->GetTarget(ev);
  1906.         FW_Boolean handled = FALSE;
  1907.         while (target != NULL && handled == FALSE)
  1908.         {
  1909.             handled = target->DispatchAdjustMenus(ev, menuBar, hasMenuFocus, rootFrame);
  1910.                 
  1911.             target = target->GetNextEventHandler(ev);
  1912.         }
  1913.     }
  1914.     FW_CATCH_BEGIN
  1915.     FW_CATCH_REFERENCE(FW_XException, exception)
  1916.     {
  1917.         FW_SetException(ev, exception);
  1918.     }
  1919. #ifdef FW_DEBUG
  1920.     FW_CATCH_EVERYTHING()
  1921.     {
  1922.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1923.         FW_SetODException(ev, kODErrUndefined);
  1924.     }
  1925. #endif
  1926.     FW_CATCH_END
  1927. }
  1928.  
  1929. //---------------------------------------------------------------------------------------
  1930. //    FW_CODPart::UndoAction
  1931. //---------------------------------------------------------------------------------------
  1932.  
  1933. void FW_CODPart::UndoAction(Environment *ev, FW_CPart* part, ODActionData* actionState)
  1934. {
  1935.     FW_TRY
  1936.     {
  1937.         // actionState may contain a pointer to the command object
  1938.         if (actionState->_maximum == sizeof(FW_CCommand*))
  1939.         {
  1940.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  1941.             command->UndoIt(ev);
  1942.         }
  1943.     }
  1944.     FW_CATCH_BEGIN
  1945.     FW_CATCH_REFERENCE(FW_XException, exception)
  1946.     {
  1947.         FW_SetException(ev, exception);
  1948.     }
  1949. #ifdef FW_DEBUG
  1950.     FW_CATCH_EVERYTHING()
  1951.     {
  1952.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1953.         FW_SetODException(ev, kODErrUndefined);
  1954.     }
  1955. #endif
  1956.     FW_CATCH_END
  1957. }
  1958.  
  1959. //---------------------------------------------------------------------------------------
  1960. //    FW_CODPart::RedoAction
  1961. //---------------------------------------------------------------------------------------
  1962.  
  1963. void FW_CODPart::RedoAction(Environment *ev, ODActionData* actionState)
  1964. {
  1965.     FW_TRY
  1966.     {
  1967.         // actionState may contain a pointer to the command object
  1968.         if (actionState->_maximum == sizeof(FW_CCommand*))
  1969.         {
  1970.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  1971.             command->RedoIt(ev);
  1972.         }
  1973.     }
  1974.     FW_CATCH_BEGIN
  1975.     FW_CATCH_REFERENCE(FW_XException, exception)
  1976.     {
  1977.         FW_SetException(ev, exception);
  1978.     }
  1979. #ifdef FW_DEBUG
  1980.     FW_CATCH_EVERYTHING()
  1981.     {
  1982.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  1983.         FW_SetODException(ev, kODErrUndefined);
  1984.     }
  1985. #endif
  1986.     FW_CATCH_END
  1987. }
  1988.  
  1989. //---------------------------------------------------------------------------------------
  1990. //    FW_CODPart::DisposeActionState
  1991. //---------------------------------------------------------------------------------------
  1992.  
  1993. void FW_CODPart::DisposeActionState(Environment *ev,
  1994.                                     ODActionData* actionState,
  1995.                                     ODDoneState doneState)
  1996. {
  1997.     FW_TRY
  1998.     {
  1999.         // actionState may contain a pointer to the command object
  2000.         if (actionState->_maximum == sizeof(FW_CCommand*))
  2001.         {
  2002.             FW_CCommand* command = *(FW_CCommand**)actionState->_buffer;
  2003.             if (doneState == kODUndone)
  2004.                 command->CommitUndone(ev);
  2005.             else    // doneState is kODDone or kODRedone
  2006.                 command->CommitDone(ev);
  2007.             delete command;
  2008.         }
  2009.     }
  2010.     FW_CATCH_BEGIN
  2011.     FW_CATCH_REFERENCE(FW_XException, exception)
  2012.     {
  2013.         FW_SetException(ev, exception);
  2014.     }
  2015. #ifdef FW_DEBUG
  2016.     FW_CATCH_EVERYTHING()
  2017.     {
  2018.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2019.         FW_SetODException(ev, kODErrUndefined);
  2020.     }
  2021. #endif
  2022.     FW_CATCH_END
  2023. }
  2024.  
  2025. //---------------------------------------------------------------------------------------
  2026. //    FW_CODPart::WriteActionState
  2027. //---------------------------------------------------------------------------------------
  2028.  
  2029. void FW_CODPart::WriteActionState(Environment *ev,
  2030.                                     ODActionData* actionState,
  2031.                                     ODStorageUnitView* storageUnitView)
  2032. {
  2033.     FW_TRY
  2034.     {
  2035.         FW_DEBUG_MESSAGE("WriteActionState: Not Yet Implemented");
  2036.     }
  2037.     FW_CATCH_BEGIN
  2038.     FW_CATCH_REFERENCE(FW_XException, exception)
  2039.     {
  2040.         FW_SetException(ev, exception);
  2041.     }
  2042. #ifdef FW_DEBUG
  2043.     FW_CATCH_EVERYTHING()
  2044.     {
  2045.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2046.         FW_SetODException(ev, kODErrUndefined);
  2047.     }
  2048. #endif
  2049.     FW_CATCH_END
  2050. }
  2051.  
  2052. //---------------------------------------------------------------------------------------
  2053. //    FW_CODPart::ReadActionState
  2054. //---------------------------------------------------------------------------------------
  2055.  
  2056. void FW_CODPart::ReadActionState(Environment *ev, ODStorageUnitView* storageUnitView, ODActionData* actionData)
  2057. {
  2058.     FW_TRY
  2059.     {
  2060.          FW_DEBUG_MESSAGE("ReadActionState: Not Yet Implemented");
  2061.     }
  2062.     FW_CATCH_BEGIN
  2063.     FW_CATCH_REFERENCE(FW_XException, exception)
  2064.     {
  2065.         FW_SetException(ev, exception);
  2066.     }
  2067. #ifdef FW_DEBUG
  2068.     FW_CATCH_EVERYTHING()
  2069.     {
  2070.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2071.         FW_SetODException(ev, kODErrUndefined);
  2072.     }
  2073. #endif
  2074.     FW_CATCH_END
  2075. }
  2076.  
  2077. //---------------------------------------------------------------------------------------
  2078. //    FW_CODPart::InitPart
  2079. //---------------------------------------------------------------------------------------
  2080.  
  2081. void FW_CODPart::InitPart(Environment *ev,
  2082.                         FW_CPart* part,
  2083.                         ODStorageUnit* storageUnit)
  2084. {        
  2085.     FW_TRY
  2086.     {
  2087.         // ----- Common initialization -----
  2088.         part->Initialize(ev);
  2089.     
  2090.         // ----- Add Needed Properties -----
  2091.         part->AddProperties(ev, storageUnit);
  2092.     }
  2093.     FW_CATCH_BEGIN
  2094.     FW_CATCH_REFERENCE(FW_XException, exception)
  2095.     {
  2096.         FW_SetException(ev, exception);
  2097.     }
  2098. #ifdef FW_DEBUG
  2099.     FW_CATCH_EVERYTHING()
  2100.     {
  2101.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2102.         FW_SetODException(ev, kODErrUndefined);
  2103.     }
  2104. #endif
  2105.     FW_CATCH_END
  2106. }
  2107.  
  2108. //---------------------------------------------------------------------------------------
  2109. //    FW_CODPart::InitPartFromStorage
  2110. //---------------------------------------------------------------------------------------
  2111.  
  2112. void FW_CODPart::InitPartFromStorage(Environment *ev,
  2113.                                     FW_CPart* part,
  2114.                                     ODStorageUnit* storageUnit)
  2115. {
  2116.     FW_TRY
  2117.     {
  2118.         // ----- Common initialization -----
  2119.         part->Initialize(ev);
  2120.         
  2121.         // ----- Read proxy frames (if any) -----
  2122.         part->PrivInternalizeProxyFrames(ev, storageUnit, NULL);
  2123.         
  2124.         // ----- Read Part Specific data -----
  2125.         part->InternalizeContent(ev, storageUnit, NULL);
  2126.     }
  2127.     FW_CATCH_BEGIN
  2128.     FW_CATCH_REFERENCE(FW_XException, exception)
  2129.     {
  2130.         FW_SetException(ev, exception);
  2131.     }
  2132. #ifdef FW_DEBUG
  2133.     FW_CATCH_EVERYTHING()
  2134.     {
  2135.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2136.         FW_SetODException(ev, kODErrUndefined);
  2137.     }
  2138. #endif
  2139.     FW_CATCH_END
  2140. }
  2141.  
  2142. //---------------------------------------------------------------------------------------
  2143. //    FW_CODPart::Externalize
  2144. //---------------------------------------------------------------------------------------
  2145.  
  2146. void FW_CODPart::Externalize(Environment *ev, FW_CPart* part)
  2147. {
  2148.     FW_TRY
  2149.     {
  2150.         ODStorageUnit* partStorageUnit = part->GetStorageUnit(ev);
  2151.         
  2152.         if (partStorageUnit->GetDraft(ev)->GetPermissions(ev) >= kODDPSharedWrite)
  2153.         {
  2154.             // ----- Write proxy frames (if any) -----
  2155.             part->PrivExternalizeProxyFrames(ev, partStorageUnit, NULL);
  2156.     
  2157.             // ----- Create the necessary properties if necessary
  2158.             part->AddProperties(ev, partStorageUnit);
  2159.                 
  2160.             // ----- Externalize part specific data -----
  2161.             part->ExternalizeContent(ev, partStorageUnit, NULL);
  2162.         }
  2163.     }
  2164.     FW_CATCH_BEGIN
  2165.     FW_CATCH_REFERENCE(FW_XException, exception)
  2166.     {
  2167.         FW_SetException(ev, exception);
  2168.     }
  2169. #ifdef FW_DEBUG
  2170.     FW_CATCH_EVERYTHING()
  2171.     {
  2172.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2173.         FW_SetODException(ev, kODErrUndefined);
  2174.     }
  2175. #endif
  2176.     FW_CATCH_END
  2177. }
  2178.  
  2179. //---------------------------------------------------------------------------------------
  2180. //    FW_CODPart::Release
  2181. //---------------------------------------------------------------------------------------
  2182.  
  2183. void FW_CODPart::Release(Environment *ev, FW_CPart* part)
  2184. {
  2185.     FW_TRY
  2186.     {
  2187.         part->Release(ev);
  2188.     }
  2189.     FW_CATCH_BEGIN
  2190.     FW_CATCH_REFERENCE(FW_XException, exception)
  2191.     {
  2192.         FW_SetException(ev, exception);
  2193.     }
  2194. #ifdef FW_DEBUG
  2195.     FW_CATCH_EVERYTHING()
  2196.     {
  2197.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2198.         FW_SetODException(ev, kODErrUndefined);
  2199.     }
  2200. #endif
  2201.     FW_CATCH_END
  2202. }
  2203.  
  2204. //---------------------------------------------------------------------------------------
  2205. //    FW_CODPart::ReleaseAll
  2206. //---------------------------------------------------------------------------------------
  2207.  
  2208. void FW_CODPart::ReleaseAll(Environment *ev, FW_CPart* part)
  2209. {
  2210.     FW_TRY
  2211.     {
  2212.         part->ReleaseAll(ev);
  2213.     }
  2214.     FW_CATCH_BEGIN
  2215.     FW_CATCH_REFERENCE(FW_XException, exception)
  2216.     {
  2217.         FW_SetException(ev, exception);
  2218.     }
  2219. #ifdef FW_DEBUG
  2220.     FW_CATCH_EVERYTHING()
  2221.     {
  2222.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2223.         FW_SetODException(ev, kODErrUndefined);
  2224.     }
  2225. #endif
  2226.     FW_CATCH_END
  2227. }
  2228.  
  2229. //---------------------------------------------------------------------------------------
  2230. //    FW_CODPart::Purge
  2231. //---------------------------------------------------------------------------------------
  2232.  
  2233. ODSize FW_CODPart::Purge(Environment *ev, FW_CPart* part, ODSize size)
  2234. {
  2235.     ODSize bytesFreed = 0;
  2236.     
  2237.     FW_TRY
  2238.     {
  2239.         bytesFreed = part->Purge(ev, size);
  2240.     }
  2241.     FW_CATCH_BEGIN
  2242.     FW_CATCH_REFERENCE(FW_XException, exception)
  2243.     {
  2244.         FW_SetException(ev, exception);
  2245.     }
  2246. #ifdef FW_DEBUG
  2247.     FW_CATCH_EVERYTHING()
  2248.     {
  2249.         FW_DEBUG_MESSAGE(FW_kInvalidException);
  2250.         FW_SetODException(ev, kODErrUndefined);
  2251.     }
  2252. #endif
  2253.     FW_CATCH_END
  2254.     
  2255.     return bytesFreed;
  2256. }
  2257.